home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ham Radio 2000
/
Ham Radio 2000.iso
/
ham2000
/
misc
/
tasm
/
misc.zoo
/
sc11lib.asm
< prev
next >
Wrap
Assembly Source File
|
1990-12-26
|
6KB
|
334 lines
*********************************************************
*
* c11lib --
* This file contains the run-time library
* routines used by the 6801 tiny-c compiler 'c01'.
* They should be appended onto the assembly code
* generated by 'c01' and the entire mess assembled
* to create a single load module.
***********************************************************
*
* Modified for compatibility with TASM. tna 12/27/90
* TASM requires a semicolon at the beginning of all
* embedded comments.
*
***********************************************************
*
* ccdchx -- Code to fetch a character into secondary
* indirect from address in primary.
*
ccdchx equ *
xgdx
clra
ldab 0,x ; get character into b */
bge *+3
coma ; sign extend char into d */
xgdx
rts
*
******************
*
* ccdnt -- Code to fetch a pointer or integer
* into primary indirect from address in primary.
*
ccdnt equ *
xgdx ; tfr addr from d to x */
ldd 0,x ; Fetch int */
rts
*********************************************
* ccmods -- Code to modify stack pointer (is in X).
*
ccmods equ *
pshx ; Add offset to stack ptr */
tsx
addd 0,x ;add Dreg + Sreg
pulx
xgdx ;answer to Xreg
rts
*
* ccswitch D reg contains the switch value
ccswit pulx ;get the return address (points to switch table)
ccsw4 pshx
ldx 0,x ;get label & check for
cpx #0 ;end of switch table
beq ccsw2
pulx
cpd 2,x ;check for case value
bne ccsw3
ldx 0,x
jmp 0,x
ccsw3 inx
inx
inx
inx
bra ccsw4
ccsw2 pulx
jmp 2,x
ccsw1 equ *
*********************************************
*
* ccmult --
* Multiplies D by X with result
* in D (signed 2's comp).
*
tmpd equ 0
tmpx equ 2
rslt equ 4
*
ccmult equ *
pshx
pshx
pshb
psha
tsx
ldaa tmpx+1,x
mul
std rslt,x
ldd tmpd+1,x ;get d-low and x-high
mul
addb rslt,x
stab rslt,x
ldaa tmpd,x ;get d-high and x-low
ldab tmpx+1,x
mul
addb rslt,x
stab rslt,x ;Will be valid 2's comp result
pulx ;peel stack down to result
pulx
pula ;return with result in D
pulb
rts
*
********************************
*
* ccor -- inclusive or
*
ccor equ *
pshx
tsx
orab 1,x
oraa 0,x
pulx
rts
********************************
*
* ccxor -- exclusive or
*
ccxor equ *
pshx
tsx
eorb 1,x
eora 0,x
pulx
rts
********************************
*
* ccand -- logical and
*
ccand equ *
pshx
tsx
andb 1,x
anda 0,x
pulx
rts
*
**********************************
* ccasl -- shift left
*
ccasl equ *
xgdx ;Move value to shift from x to d
asllpa equ *
cpx #0
ble aslret
aslb
rola
dex
bra asllpa
aslret equ *
rts
*
***************************************
* cceq -- test X equal D
* 1=true, 0=false
*
cceq equ *
pshx
tsx
cpd 0,x
bne noteq
ldd #1
pulx
rts
noteq equ *
ldd #0
pulx
rts
*
***************************************
* ccne -- test X not equal D
* 1=true, 0=false
*
ccne equ *
pshx
tsx
cpd 0,x
beq notne
ldd #1
pulx
rts
notne equ *
ldd #0
pulx
rts
*
********************************
* ccasr -- shift right
*
ccasr equ *
xgdx ;Move value to shift from x to d, count from d to x
asrlpa equ *
cpx #0
ble asret
asra
rorb
dex
bra asrlpa
asret equ *
rts
*
*
***************************************
* cclt -- test X less than D
* 1=true, 0=false
*
cclt equ *
pshx
tsx
cpd 0,x
pulx
ble notlt
ldd #1
rts
notlt equ *
ldd #0
rts
*
***************************************
* ccle -- test X less or equal D
* 1=true, 0=false
*
ccle equ *
pshx
tsx
cpd 0,x
pulx
blt notle
ldd #1
rts
notle equ *
ldd #0
rts
*
***************************************
* ccgt -- test X greater than D
* 1=true, 0=false
*
ccgt equ *
pshx
tsx
cpd 0,x
pulx
bge notgt
ldd #1
rts
notgt equ *
ldd #0
rts
*
***************************************
* ccge -- test X greater or equal D
* 1=true, 0=false
*
ccge equ *
pshx
tsx
cpd 0,x
pulx
bgt notge
ldd #1
rts
notge equ *
ldd #0
rts
*
***************************************
* ccult -- test X less than(unsigned) D
* 1=true, 0=false
*
ccult equ *
pshx
tsx
cpd 0,x
pulx
bls notult
ldd #1
rts
notult equ *
ldd #0
rts
*
***************************************
* ccule -- test X less than or equal(unsigned) D
* 1=true, 0=false
*
ccule equ *
pshx
tsx
cpd 0,x
pulx
blo notule
ldd #1
rts
notule equ *
ldd #0
rts
*
***************************************
* ccugt -- test X greater(unsigned) D
* 1=true, 0=false
*
ccugt equ *
pshx
tsx
cpd 0,x
pulx
beq notugt
bhs notugt
ldd #1
rts
notugt equ *
ldd #0
rts
*
***************************************
* ccuge -- test X greater or equal D
* (unsigned)
* 1=true, 0=false
*
ccuge equ *
pshx
tsx
cpd 0,x
pulx
bhi notuge
ldd #1
rts
notuge equ *
ldd #0
rts